﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Poco;

namespace WebApp
{
    public class CommandModelView 
    {
        //
        // GET: /CommandModelView/

        public List<Plat> All_Plats { get; set; }
        public List<Plat> All_Commande { get; set; }



        public CommandModelView()
        {
            All_Plats = new List<Plat>();
            All_Commande = new List<Plat>();

        }
        public CommandModelView(List<Plat> plats)
        {
            if (plats != null)
                this.All_Plats = plats;
        }
        public List<Plat> Entrees
        {
            get { return this.getListPlatByType(All_Plats,TypePlat.Entrée); }
        }
        public List<Plat> Plat
        {
            get { return this.getListPlatByType(All_Plats,TypePlat.PlatPrincipal); }
        }
        public List<Plat> Dessert
        {
            get { return this.getListPlatByType(All_Plats, TypePlat.Dessert); }
        }
        public List<Plat> Boisson
        {
            get { return this.getListPlatByType(All_Plats, TypePlat.Boisson); }
        }
        public List<Plat> Formule
        {
            get { return this.getListPlatByType(All_Plats,TypePlat.Autres); }
        }

        public List<Plat> getListPlatByType(List<Plat> list, TypePlat type)
        {
            List<Plat> mylist = new List<Plat>();
            if (list != null)
            {
                foreach (Plat item in list)
                {
                    Plat myplat = item;
                    if (item.getType().Equals(type))
                        mylist.Add(item);
                }
            }
            return mylist;
        }
        public List<Plat> getListPlatByType(List<Plat> list, string type)
        {
            List<Plat> mylist = new List<Plat>();
            if (list != null)
            {
                foreach (Plat item in list)
                {
                    Plat myplat = item;
                    if (item.getType().ToString().Equals(type))
                        mylist.Add(item);
                }
            }
            return mylist;
        }


    }
}
